﻿namespace Sidvall.WorkItemManager.Net.Services.V1.ConfigModel
{
    public class ResourceFactory : global::Sidvall.Data.IResourceFactory
    {
        #region CreateItem

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
        public object CreateItem(string resource, Sidvall.Data.DataRowState? dataRowState)
        {
            switch (resource)
            {
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.UserConfiguration:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.UserConfiguration(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.ServerConnection:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.ServerConnection(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.Schedule:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.Schedule(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.IntervalRetryPolicy:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.IntervalRetryPolicy(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.MonitoredWorkItem:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.MonitoredWorkItem(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.MonitorContext:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.MonitorContext(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.WorkItemAlarm:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WorkItemAlarm(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.MonitorExecutionContext:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.MonitorExecutionContext(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.IdentityProvider:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.IdentityProvider(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.WebExecutionContext:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WebExecutionContext(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.WebContext:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WebContext(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.WebTarget:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WebTarget(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.WebResult:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WebResult(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                default:
                    return null;
            }
        }

        #endregion
        #region CreateItems

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
        public object CreateItems(string resource)
        {
            switch (resource)
            {
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.UserConfiguration:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.UserConfigurationCollectionItem();
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.ServerConnection:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.ServerConnectionCollectionItem();
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.Schedule:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.ScheduleCollectionItem();
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.IntervalRetryPolicy:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.IntervalRetryPolicyCollectionItem();
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.MonitoredWorkItem:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.MonitoredWorkItemCollectionItem();
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.MonitorContext:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.MonitorContextCollectionItem();
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.WorkItemAlarm:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WorkItemAlarmCollectionItem();
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.MonitorExecutionContext:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.MonitorExecutionContextCollectionItem();
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.IdentityProvider:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.IdentityProviderCollectionItem();
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.WebExecutionContext:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WebExecutionContextCollectionItem();
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.WebContext:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WebContextCollectionItem();
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.WebTarget:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WebTargetCollectionItem();
                case global::Sidvall.WorkItemManager.Data.ConfigModel.DomainObjects.WebResult:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WebResultCollectionItem();
                default:
                    return null;
            }
        }
        
        #endregion
        
        #region Current

        private static readonly System.Lazy<ResourceFactory> _Current = new System.Lazy<ResourceFactory>(() => new ResourceFactory());
        public static ResourceFactory Current
        {
            get
            {
                return _Current.Value;
            }
        }

        #endregion
    }
}